package product.infrastructure.repository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import product.domain.model.Product;
import product.domain.repository.ProductRepository;

import java.util.List;
import java.util.Optional;

@Repository
public class ProductRepositoryImpl implements ProductRepository {

    @Autowired
    private JpaProductRepository jpaProductRepository;

    @Override
    public Product save(Product product) {
        return jpaProductRepository.save(product);
    }

    @Override
    public void deleteById(Integer productId) {
        jpaProductRepository.deleteById(productId);
    }

    @Override
    public Optional<Product> findById(Integer productId) {
        return jpaProductRepository.findById(productId);
    }

    @Override
    public List<Product> findAll() {
        return jpaProductRepository.findAll();
    }

    @Override
    public List<Product> findByUserId(Long userId) {
        return jpaProductRepository.findByUserId(userId);
    }

    @Override
    public List<Product> findByCategory(String category) {
        return jpaProductRepository.findByCategory(category);
    }
}